home *** CD-ROM | disk | FTP | other *** search
- package com.extensibility.app;
-
- import com.extensibility.plugin.api.PrintHtml10;
- import com.extensibility.print.HtmlPrinter;
- import com.extensibility.rock.QuietBtn;
- import com.extensibility.rock.RAction;
- import com.extensibility.util.History;
- import com.extensibility.util.RuleSplitPane;
- import java.awt.BorderLayout;
- import java.awt.Component;
- import java.awt.Cursor;
- import java.awt.Dimension;
- import java.awt.Font;
- import java.awt.Frame;
- import java.awt.event.ActionEvent;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.IOException;
- import java.net.URL;
- import java.util.EventObject;
- import javax.swing.JEditorPane;
- import javax.swing.JFrame;
- import javax.swing.JMenuBar;
- import javax.swing.JScrollPane;
- import javax.swing.JToolBar;
- import javax.swing.event.HyperlinkEvent;
- import javax.swing.event.HyperlinkListener;
- import javax.swing.event.HyperlinkEvent.EventType;
-
- public class HelpWindow extends BaseWindow implements HyperlinkListener {
- JEditorPane helpText;
- JScrollPane helpScroller;
- JEditorPane indexText;
- JScrollPane indexScroller;
- RuleSplitPane split;
- JToolBar toolbar;
- BaseAction forwardAction;
- BaseAction backAction;
- BaseAction homeAction;
- BaseAction printAction;
- RAction copyAction;
- QuietBtn forwardBtn;
- QuietBtn backBtn;
- URL index;
- URL home;
- History history;
- boolean userHasBeenWarned;
-
- private HelpWindow() {
- super(new BaseDocument());
- this.history = new History();
- ((JFrame)this).getContentPane().setLayout(new BorderLayout());
- this.setVisible(false);
- ((BaseWindow)this).setSize(640, 340);
- ((Component)this).setFont(new Font("Serif", 0, 9));
- this.createToolBar();
- ((JFrame)this).getContentPane().add(this.toolbar, "North");
- ((Frame)this).setIconImage(UI.getImage("ity.gif"));
- }
-
- protected String getHomeShortName() {
- if (this.home == null) {
- return null;
- } else {
- String var1 = this.home.getFile();
- return var1.substring(var1.lastIndexOf("/") + 1);
- }
- }
-
- public void setTitle() {
- String var1 = UI.getString(this.getClassName());
- ((Frame)this).setTitle(var1);
- }
-
- public HelpWindow(String var1) {
- this();
- this.createContent(var1);
- ((JFrame)this).getContentPane().add(this.helpScroller, "Center");
- ((Frame)this).setIconImage(UI.getImage("ity.gif"));
- this.homeAction.actionOccurred((ActionEvent)null);
- }
-
- public HelpWindow(String var1, int var2, String var3) {
- this();
- this.createIndex(var1);
- this.createContent(var3);
- this.split = new RuleSplitPane(1, this.indexScroller, this.helpScroller);
- this.split.setDividerRule(true, var2);
- ((JFrame)this).getContentPane().add(this.split, "Center");
- ((Frame)this).setIconImage(UI.getImage("ity.gif"));
- this.homeAction.actionOccurred((ActionEvent)null);
- }
-
- public void setVisible(boolean var1) {
- super.setVisible(var1);
- if (var1 && this.split != null) {
- this.split.resetDividerLoc();
- }
-
- }
-
- private JScrollPane createIndex(String var1) {
- this.index = UI.getHelpURL(var1);
-
- try {
- this.indexText = new JEditorPane(this.index);
- } catch (IOException var3) {
- DialogFactory.showException(this, 101, var3);
- this.indexText = new JEditorPane();
- }
-
- this.indexText.setEditable(false);
- this.indexText.addHyperlinkListener(this);
- this.indexText.setCursor(Cursor.getPredefinedCursor(12));
- this.indexScroller = new JScrollPane(this.indexText);
- this.indexScroller.setMinimumSize(new Dimension(20, 20));
- this.indexText.setMinimumSize(new Dimension(300, 100));
- return this.indexScroller;
- }
-
- protected JMenuBar createMenuBar() {
- return null;
- }
-
- private JScrollPane createContent(String var1) {
- this.home = UI.getHelpURL(var1);
- this.setTitle();
- this.helpText = new JEditorPane();
- this.helpText.setEditable(false);
- this.helpText.addHyperlinkListener(this);
- this.helpText.setCursor(Cursor.getPredefinedCursor(12));
- this.helpScroller = new JScrollPane(this.helpText);
- return this.helpScroller;
- }
-
- private JToolBar createToolBar() {
- this.backAction = new BackAction(this);
- this.forwardAction = new ForwardAction(this);
- this.homeAction = new HomeAction(this);
- this.printAction = new PrintAction(this);
- this.copyAction = new CopyAction((HelpWindow)null);
- this.toolbar = new BaseToolBar();
- this.toolbar.setFloatable(false);
- this.forwardBtn = new QuietBtn(this.forwardAction, false);
- this.backBtn = new QuietBtn(this.backAction, false);
- this.toolbar.add(new QuietBtn(this.homeAction, false));
- this.toolbar.add(this.backBtn);
- this.toolbar.add(this.forwardBtn);
- this.toolbar.addSeparator();
- this.toolbar.add(new QuietBtn(this.copyAction, true));
- if (HtmlPrinter.canPrint()) {
- this.toolbar.add(new QuietBtn(this.printAction, true));
- }
-
- return this.toolbar;
- }
-
- public void showPage(String var1) {
- URL var2 = UI.getHelpURL(var1);
- this.showPage(var2, true);
- }
-
- protected void showPage(URL var1, boolean var2) {
- if (var1 == null) {
- DialogFactory.showException(this, 101, new FileNotFoundException());
- } else {
- try {
- this.helpText.setPage(var1);
- if (var2) {
- this.history.add(var1);
- }
-
- this.updateNavigationActions();
- } catch (IOException var4) {
- DialogFactory.showException(this, 101, var4);
- }
-
- }
- }
-
- private void warnUser(URL var1) {
- this.userHasBeenWarned = true;
- DialogFactory.caution(this, UI.getString("caution.lousy.browser", var1.toExternalForm()));
- }
-
- public void hyperlinkUpdate(HyperlinkEvent var1) {
- if (var1.getEventType() == EventType.ACTIVATED) {
- this.showPage(var1.getURL(), ((EventObject)var1).getSource() == this.helpText);
- } else if (var1.getEventType() == EventType.ENTERED) {
- this.helpText.setCursor(Cursor.getPredefinedCursor(12));
- } else if (var1.getEventType() == EventType.EXITED) {
- this.helpText.setCursor(Cursor.getPredefinedCursor(2));
- }
-
- }
-
- protected void updateNavigationActions() {
- this.forwardBtn.setEnabled(this.history.peekNext() != null);
- this.backBtn.setEnabled(this.history.peekPrev() != null);
- }
-
- public String getClassName() {
- return "com.extensibility.app.HelpWindow";
- }
-
- public void setHome(String var1) {
- this.home = UI.getHelpURL(var1);
- }
-
- public void printWindow(ActionEvent var1) {
- try {
- PrintHtml10 var2 = HtmlPrinter.getPrintObject();
- if (var2 != null) {
- var2.setHtmlToPrint(this.helpText.getPage());
- var2.doPrinting((File)null);
- }
- } catch (Exception var3) {
- DialogFactory.showException(this, 124, var3);
- }
-
- }
-
- protected String getText() {
- return null;
- }
- }
-